package cn.liulin.java8.simplestudy;

import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * cn.liulin.java8.simplestudy$
 *
 * @author ll
 * @date 2024-03-21 18:15:44
 **/
public class ArrayTest {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            list.add(i);
        }
        System.out.println(list);
        System.out.println(JSON.toJSONString(list));
        for (int i = 0; i < 100; i++) {
            Integer remove = list.remove(0);
            System.out.println(remove);
            System.out.println(JSON.toJSONString(list));
        }
    }

    public static void test1() {
        long l1, l2;
        System.out.println("==========> startTime" + (l1 = System.currentTimeMillis()));
        MyArrayList myArrayList = new MyArrayList();
        for (int i = 0; i <= 10000000; i++) {
            myArrayList.add(1);
        }
        for (int i = 0; i <= 10000000; i++) {
            myArrayList.remove(0);
            System.out.println(i);
        }
        System.out.println("==========> endTime" + (l2 = System.currentTimeMillis()));
        System.out.println("==========> sumTime" + (l2 - l1));
    }

    public static void test2() {
        long l1, l2;
        System.out.println("==========> startTime" + (l1 = System.currentTimeMillis()));
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i <= 10000000; i++) {
            list.add(1);
        }
        for (int i = 0; i <= 10000000; i++) {
            list.remove(0);
            System.out.println(i);
        }
        System.out.println("==========> endTime" + (l2 = System.currentTimeMillis()));
        System.out.println("==========> sumTime" + (l2 - l1));
    }
}
